﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Http;
using Common.Logging;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Loger;
using Learun.Util;
using Learun.Util.Operat;
using log4net.Config;
using Pipelines.Sockets.Unofficial.Arenas;

namespace Learun.Application.Web.AppApi
{
    /// <summary>
    /// 权限的接口
    /// </summary>
    [RoutePrefix("api/AccessApi")]
    [HandlerApiLogin(FilterMode.Ignore)]
    public class AccessApiController : WebApiControllerBase
    {
        /// <summary>
        /// 当前登录用户下。根据某个权限类型，去查询所有记录
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="EntityTableID">如ec_drawing_file</param>
        /// <returns></returns>
        [HttpGet]
        [HandlerApiLogin(FilterMode.Enforce)]
        public IHttpActionResult GetListByAccessType(string ProjectId, string EntityTableID)
        {
            var res = new ec_accessBLL().GetList("{ProjectId:\"" + ProjectId + "\", EntityTableID: \"" + EntityTableID + "\"}");// "{ProjectId:\"" + ProjectId + "\", EntityTableID: \"" + EntityTableID + "\"}"
            return Success(res);
        }

        /// <summary>
        /// 查询某个图纸能被哪些用户编辑
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="DrawingID"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetAllUsersCanEditDrawing(string ProjectId, string DrawingID)
        {
            var res = new ec_accessBLL().GetAllUsersCanEditDrawing(ProjectId, DrawingID);// "{ProjectId:\"" + ProjectId + "\", EntityTableID: \"" + EntityTableID + "\"}"

            return Success(res );
        }
    }
}